//导入工具类
import request from "@/utils/request";

//查询所有文章
export const getAllArticle = (PageNum,PageSize) =>{
    let page = {
        PageNum:PageNum,
        PageSize:PageSize
    }
    return request.get("/article/selectArticle",page);
}

//根据id查询用户
export const getUserById = (userId) =>{
    return request.get(`/user/${userId}`);
}

//查询总页数
export const getAllPage = () =>{
    return request.get("/article");
}

//删除文章
export const deleArticle = (id) =>{
    let article = {
        articleId:id,
    }
    return request.get("/article/delArticle",article);
}

//添加文章
export const addArticle = (newArticle) =>{
    let art = {
        articleTitle:newArticle.newTitle,
        articleContent:newArticle.newContent,
        userId:newArticle.userId
    }
    return request.post("/article/insertArticle",art);
}

//模糊查询文章
export const searchArticle = (words,PageNum,PageSize) =>{
    let article = {
        articleTitle:words,
        articleContent:words,
        PageNum:PageNum,
        PageSize:PageSize,
    }
    return request.post("/article/selectLike",article);
}

//查询总标签
export const getAllTags = () =>{
    return request.get("/title");
}

//添加文章标签
export const addArticleTags = (articleId,titleId) =>{
    let article = {
        articleId:articleId,
        titleId:titleId,
    }
    return request.post("/article/insertArticleTitle",article);
}


//修改文章
export const changeArticle = (changeArt) =>{
    return request.post("/article/updateArticle",changeArt);
}